<template>
    <div class="inter">
        <order-list-top @searchCon="searchCon"></order-list-top>
        <ul>
            <li v-for="item in orderList" :key="item.id" @click="toOrderDetail(item.order_id)">
                <order-list-cell :item="item"></order-list-cell>
            </li>
            <listload :stateLoad="stateLoad"></listload>
        </ul>
    </div>
</template>
<script type="text/ecmascript-6">
  import OrderListCell from '@/components/spread/OrderListCell.vue';
  import OrderListTop from '@/components/spread/OrderListTop.vue';
  export default {
    name: `menberlistorderlist`,
    components: {OrderListCell, OrderListTop},
    data() {
      return {
        state: true,
        typeId: this.$route.params.typeId, // 传过来的typeid，用来查这个人的订单(给我返利的)
        orderList: {}, // 订单列表数据
        stateLoad: true // 加载动画
      };
    },
    created() {
      console.log('asda', this.typeId);
      this.date = new Date().toLocaleDateString();
      this.getDataL();
    },
    methods: {
      getDataL() {
        // 查询用户的订单列表
        this.stateLoad = true; // 加载动画
        this.orderList = {}; // 清空数据
        this.$Spread.getmemListOrder().then(res => {
          this.orderList = res;
          console.log(this.orderList);
          this.stateLoad = false;
        });
      },
      toOrderDetail(orderId) {
        // 跳转到订单详情
        this.$router.push({name: 'menorderdetail', params: {orderId: orderId}});
      },
      searchCon(index) {
        // 查询全部月日, index对应(1、2、3)
        this.getDataL();
      }
    }
  };
</script>

<style lang="stylus" rel="stylesheet/stylus" scoped>
    @import "../../assets/stylus/main.styl"
</style>
